const app = getApp()
import Toast from '@vant/weapp/toast/toast'
import Dialog from '@vant/weapp/dialog/dialog';
import Notify from '@vant/weapp/notify/notify';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    sign: null,
    ispopupShow: false,
    baseobject:null,
    BmstateValue: '',
    BmstateIndex:0,
    columnsBmState:[{
      id: 0,
      text: '选择区域'
    }, {
      id: 1,
      text: '吴中区'
    }, {
      id: 2,
      text: '相城区'
    }],
    customStyleSelect: "padding:0 0 0 20rpx;height: 100%;width:calc(100% - 20rpx);color:#808285;",
    listData:[
      {
        id:1,
        coding:'CN001',
        equipment_state:0,
        operation_state:0,
        url_image:'https://img.yzcdn.cn/vant/cat.jpeg'
      },
      {
        id:2,
        coding:'CN002',
        equipment_state:1,
        operation_state:1,
        url_image:'https://img.yzcdn.cn/vant/cat.jpeg'
      },
      {
        id:2,
        coding:'CN002',
        equipment_state:1,
        operation_state:1,
        url_image:'https://img.yzcdn.cn/vant/cat.jpeg'
      },{
        id:2,
        coding:'CN002',
        equipment_state:1,
        operation_state:1,
        url_image:'https://img.yzcdn.cn/vant/cat.jpeg'
      },{
        id:2,
        coding:'CN002',
        equipment_state:1,
        operation_state:1,
        url_image:'https://img.yzcdn.cn/vant/cat.jpeg'
      },{
        id:2,
        coding:'CN002',
        equipment_state:1,
        operation_state:1,
        url_image:'https://img.yzcdn.cn/vant/cat.jpeg'
      },{
        id:2,
        coding:'CN002',
        equipment_state:1,
        operation_state:1,
        url_image:'https://img.yzcdn.cn/vant/cat.jpeg'
      },
    ],
    result:[]
  },
  submit(){
    let that = this
    console.log('提交',that.data.result);
    if(that.data.result.length>0){
      wx.navigateTo({
        url: '/pages/batchhandle/batchhandle?ids='+ JSON.stringify(that.data.result),
      })
    }else{
      Notify({
        type: 'warning',
        background: '#48C1BF',
        message: '请勾选设备'
      });
    }
    
  },
  onChangecheckbox(event) {
    let that = this
    that.setData({
      result: event.detail,
    });
    console.log(that.data.result,'选中');
  },
  onClickInput(e) {
    let that = this
    that.setData({
      sign: e.currentTarget.dataset.sign,
      ispopupShow: true
    })
  },
  cancelpicker(e) {
    let that = this
    that.setData({
      ispopupShow: false
    })
    setTimeout(()=>{
      that.setData({
        sign:null
      })
    },200)
  },
   //层级
   onConfirmBmState(event) {
    let that = this
    that.setData({
      BmstateIndex:event.detail.index,
      BmstateValue: event.detail.value.id == 0 ? '' : event.detail.value.text,
      ispopupShow: false
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    let that = this
    that.setData({
      baseobject:JSON.parse(options.id)
    })
    console.log(JSON.parse(options.id));
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {
    // let that = this
    // wx.setStorageSync('unitValuesp',that.data.unitValuesp)
    // wx.setStorageSync('isOpensp',that.data.isOpensp)
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})